
from util.selenium.webdriver.common.by import By

from base.BaseMethod import BM
from PageObject.WriteHrInfo import WriteHRInfo
from PageObject.WriteHrSubinfo import WriteHRSubinfo


class WriteHRForm():

    form_btn_loc = (By.LINK_TEXT, '人力资源情况表')
    content_iframe_loc = (By.CSS_SELECTOR, "#innocomFrame")
    title_loc = (By.CSS_SELECTOR, 'h2.text-center')

    upload_btn_loc = (By.CSS_SELECTOR, '.uploadAttachment a.btn')
    save_btn_loc = (By.CSS_SELECTOR, '.box-footer.text-right #dataEnmanressave')

    # 写代码时方便提示, 基本方法完成后删除
    # driver = driver
    def __init__(self, driver=None):
        self.driver = driver

    @property
    def class_name(self):
        return self.__class__.__name__

    def main(self):
        BM.click(driver=self.driver, ele_loc=self.form_btn_loc)
        BM.cut_over_frame(driver=self.driver, selector_loc=self.content_iframe_loc)
        BM.wait(driver=self.driver, ele_loc=self.title_loc)
        BM.wait(driver=self.driver, ele_loc=self.save_btn_loc)
        # # # # # # # # # #  数据查询模块实现后需要先查询数据，在调用 write_hr_info 、 write_hr_subinfo 方法
        WriteHRInfo(driver=self.driver).write_hr_info()
        WriteHRSubinfo(driver=self.driver).write_hr_subinfo()

        # # # TODO 上传附件
        BM.click_upload(btn_loc=self.upload_btn_loc, driver=self.driver, class_name=self.class_name)
        BM.global_click_btn(btn_loc=self.save_btn_loc, driver=self.driver)

